package com.dyz.leetcode;

public class MaxProfit121 {
    public int maxProfit(int[] prices) {
        int ans = 0;
        if(prices==null||prices.length==0||prices.length==1){return ans;}
        int min = Integer.MAX_VALUE;

        for(int i=0; i<prices.length;i++){
            if(prices[i]<min){min=prices[i];}
            if(prices[i]-min>ans){ans=prices[i]-min;}
        }
        return ans;
    }
}
